package com.cdream.basic.spring.factorybean;

import org.aspectj.lang.ProceedingJoinPoint;

import java.util.HashMap;
import java.util.Map;

/**
 * @author cdream
 * @date 2021/10/29
 */
public class LogTestAspect {
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("切面前面干了坏事");
        Object proceed = joinPoint.proceed();
        System.out.println("连接点后面");
        return proceed;
    }

    public static void main(String[] args) {
        new LogTestAspect().longestPalindrome("sdfsdfa");
    }
    public int longestPalindrome(String s) {
        Map<Character,Integer> map = new HashMap<Character,Integer>();
        for(char c : s.toCharArray()) {
            map.merge(c,1,(a,b)-> a+1);
        }
        int count = 0;
        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
            Integer v = entry.getValue();
            count += v / 2 * 2;
        }
        if(count<s.length()){
            count+=1;
        }
        return count;
    }
}
